package com.example.counter;

import com.example.counter.service.PubStockServiceImpl;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
@EnableDiscoveryClient
@EnableFeignClients
@MapperScan("com.example.counter.mapper")
@RestController
public class CounterApplication {
    @Autowired
    private PubStockServiceImpl pubStockService;

    public static void main(String[] args) {
        SpringApplication.run(CounterApplication.class, args);
    }

    /**
     * @return java.lang.String
     * @description 订单修改、扣减库存
     * （1）订单状态修改 确认中-待支付
     * （2）并扣减库存
     * @date 2021/3/26 23:32
     * @author Jim
     **/

    @GetMapping("/{orderNo}")
    public String get(@PathVariable Long orderNo) {
        pubStockService.orderDeductionOfInventory(orderNo);
        return "success";
    }
}
